﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBUtil.FastEntity
{
    public class EntitySetting
    {
        public const string ExtendKey = "00000000000000000000000000000000000000";

        //返回的是直接作为
        public Func<object> GetUserIdString { get; set; } = () => DotNetCommon.User.Current.IdString;
        public Func<object> GetNow { get; set; } = () => DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

        public List<Action<EntityCurdBeforeArgument>> CurdBefore = new List<Action<EntityCurdBeforeArgument>>();
        public List<Action<EntityCurdAfterArgument>> CurdAfter = new List<Action<EntityCurdAfterArgument>>();

        public List<Action<EntityInfoAfterArgument>> EntityInfoAfter = new List<Action<EntityInfoAfterArgument>>();
    }

    public class EntityCurdBeforeArgument
    {
        /// <summary>
        /// 即将执行的sql
        /// </summary>
        public string Sql { get; set; }
        /// <summary>
        /// 生成sql耗费的时间
        /// </summary>
        public TimeSpan TimeSpan { get; set; }
    }

    public class EntityCurdAfterArgument
    {
        /// <summary>
        /// 已经执行的sql
        /// </summary>
        public string Sql { get; set; }
        /// <summary>
        /// 执行sql耗费的时间
        /// </summary>
        public TimeSpan TimeSpan { get; set; }
    }

    public class EntityInfoAfterArgument
    {
        public DBAccess db { get; set; }
        public EntityInfo EntityInfo { get; set; }
    }
}
